{extend name='main'}
{block name="button"}
{if auth("add_message")}
<button data-open='{:url("add_banner",["id"=>0])}' data-title="添加轮播图" class='layui-btn layui-btn-sm layui-btn-primary'>添加轮播图</button>
{/if}
{/block}

{block name="content"}
<div class="think-box-shadow">
    <table class="layui-table margin-top-15" lay-skin="line">
        {notempty name='list'}
        <thead>
        <tr>
            <th class='text-left nowrap'>图片</th>
            <th class='text-left nowrap'>url</th>
            {if auth("edit_home_msg")}
            <th class='text-left nowrap'>操作</th>
            {/if}
        </tr>
        </thead>
        {/notempty}
        <tbody>
        {foreach $list as $key=>$vo}
        <tr>
            <td class='text-left nowrap'>
                <img src="{$vo.image}" alt="" width="100">
            </td>
            <td class='text-left nowrap'>{$vo.url}</td>

            <td class='text-left nowrap'>
                {if auth("edit_home_msg")}
                <a class="layui-btn layui-btn-xs layui-btn" data-open="{:url('edit_banner',['id'=>$vo.id])}" data-value="id#{$vo.id}" style='background:green;'>编辑</a>
                <a class="layui-btn layui-btn-xs layui-btn" onClick="del_message({$vo.id})" style='background:red;'>删除</a>
                {/if}

            </td>
        </tr>
        {/foreach}
        </tbody>
    </table>

</div>
<script>
    function del_message(id){
        layer.confirm("确认要删除吗，删除后不能恢复",{ title: "删除确认" },function(index){
            $.ajax({
                type: 'POST',
                url: "{:url('del_banner')}",
                data: {
                    'id': id,
                    '_csrf_': "{:systoken('del_banner')}"
                },
                success:function (res) {
                    layer.msg(res.info,{time:2500});
                    location.reload();
                }
            });
        },function(){});
    }
</script>

{/block}